<template>
	<view>
		<u-search :show-action="true" action-text="搜索" v-model="searchForm.orderNo" @search="inputOrder" @custom="inputOrder" margin="20rpx 50rpx"></u-search>
		<view class="uni-container">
			<uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
				<uni-tr>
					<uni-th width="100" align="center">设置</uni-th>
					<uni-th align="center">订单号</uni-th>
					<uni-th align="center">款号</uni-th>
					<uni-th align="center">品名</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td>
						<view class="uni-group">
							<button class="uni-button" size="mini" type="primary"
								@click="onClickOrder(item)">选择</button>
						</view>
					</uni-td>
					<uni-td>{{ item.orderNo }}</uni-td>
					<uni-td>{{ item.styleNo }}</uni-td>
					<uni-td>{{ item.styleName }}</uni-td>
				</uni-tr>
			</uni-table>
			<!-- 				<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="change" /></view> -->
		</view>
	</view>
</template>

<script>
	import customerMobileService from '@/api/test/customer/testCustomerLeaveService'
	export default {
		data() {
			return {
				searchForm: {
					orderNo: '',
					styleNo: '',
				},
				tableData: [],
				// 每页数据量
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				loading: false
			}
		},
		onLoad() {
			this.getData(1)
		},
		methods: {

			// 分页触发
			change(e) {
				this.getData(e.current)
			},
			// 搜索
			inputOrder() {
				this.getData(1, this.searchForm)
			},
			onClickOrder(item) {
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('acceptOrderData', item);
				uni.navigateBack();
			},
			// 获取数据
			getData(pageCurrent, value = '') {
				this.loading = true
				this.pageCurrent = pageCurrent
				customerMobileService.queryStyleData({
					...this.searchForm
				}).then((data) => {
					this.tableData = data
					// 		this.total = res.total
					this.loading = false
				})

			},
		}
	}
</script>

<style>

	.uni-group {
		display: flex;
		align-items: center;
	}
</style>